package com.example.design.pattern.behavior.chain;

public abstract class AbstractLogger {

    public static final int INFO = 1;
    public static final int DEBUG = 2;
    public static final int ERROR = 3;
    
    protected AbstractLogger nextLogger;

    public void setNextLogger(AbstractLogger nextLogger) {
        this.nextLogger = nextLogger;
    }
    
    public void log(int level, String message) {
        if (getLevel() <= level) {
            doLog(message);
        }
        
        if (nextLogger != null) {
            nextLogger.log(level, message);
        }
    }

    abstract protected int getLevel();

    abstract protected void doLog(String message);
}
